package leetcode.easy;

/**
 * ClassName: $167_TwoSumII
 * Description:
 * date: 2021-10-21 10:49
 *
 * @author liyifan
 */
public class $167_TwoSumII {
    public int[] twoSum(int[] numbers, int target) {
        int l = 0;
        int r = numbers.length - 1;
        while (l < r) {
            int sum = numbers[l] + numbers[r];
            if (sum < target) {
                l++;
            } else if (sum > target) {
                r--;
            } else {
                break;
            }
        }
        return new int[] {l + 1, r + 1};
    }
}
